<template>
    <div>
        订单<br>
        <div v-for="(i,index) in list" :key="index">
      <van-card
        :title=i.produce
        :thumb="i.url">
        <template #footer>
            <van-button @click="aa(i.url)">评论</van-button>
  </template>
</van-card>
      <hr>
    </div> 


    <van-popup v-model="show" position="bottom" :style="{ height: '30%' }" >
        <van-cell-group>
  <van-field v-model="value"  label="文本"  />
</van-cell-group>
<van-button type="primary" @click="submit2">提交</van-button>
    </van-popup>
    </div>
</template>

<script>
import order2 from '@/api/order'
import pl from '@/api/Pinglun'
import { Toast } from 'vant'
export default {
    data(){
        return{
            show: false,
            url:'',
            userid:'',
            list:[],
            text:'22222222222',
            pl:[],
            value:'',
            plurl:'',
        }
    },
    methods:{
        aa(num){
            this.show = true;
            this.plurl = num
        },
        submit2(){
            let text2 = {
              url:this.plurl,
              text:this.value
            }
            console.log(text2)
            // this.pl.push(text2)
            // console.log(this.pl[0])
            pl.insert(text2)
        }
    },
    created(){//从订单表根据uid加载数据，
        if (this.$route.params && this.$route.params.id){
          this.userid= this.$route.params.id
          console.log(this.userid)
          order2.getOrder(this.userid).then(res =>{
              console.log(res.data)
            //   
                for(var i=0;i<res.data.length;i++){
             
              let list2 = {
                produce:res.data[i].produce,
                url:res.data[i].url
              }
              this.list.push(list2)
            }
            // 
          })
      }
    }
}
</script>
